from pages.base_page import BasePage


class MessagePage(BasePage):
    notice_button = '//*[@resource-id="cool.dingstock.mobile:id/scroll_view"]/android.widget.FrameLayout[1]/android.widget.LinearLayout[2]/android.widget.FrameLayout[1]/android.widget.LinearLayout[1]'
    private_message_button = '//*[@resource-id="cool.dingstock.mobile:id/scroll_view"]/android.widget.FrameLayout[1]/android.widget.LinearLayout[2]/android.widget.FrameLayout[2]/android.widget.LinearLayout[1]'
    comment_reply = '//*[@resource-id="cool.dingstock.mobile:id/tab_layout"]/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.widget.LinearLayout[2]/android.widget.FrameLayout[2]/android.widget.LinearLayout[1]'
    like_button = '//*[@resource-id="cool.dingstock.mobile:id/tab_layout"]/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.widget.LinearLayout[2]/android.widget.FrameLayout[3]/android.widget.LinearLayout[1]'
    follow_button = '//*[@resource-id="cool.dingstock.mobile:id/tab_layout"]/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.widget.LinearLayout[2]/android.widget.FrameLayout[4]/android.widget.LinearLayout[1]'
    user_list = '//*[@resource-id="cool.dingstock.mobile:id/iv_icon_menu"]'
    title = '//*[@resource-id="cool.dingstock.mobile:id/common_titlebar_title_tv"]'
    my_follow = '//*[@text="我的关注"]'
    my_fans = '//*[@text="我的粉丝"]'
    clean_message_button = '//*[@resource-id="cool.dingstock.mobile:id/iv_clear"]'
    clean_message_confirm = '//*[@resource-id="cool.dingstock.mobile:id/confirm_tv"]'
    clean_message_cancel = '//*[@resource-id="cool.dingstock.mobile:id/cancel_tv"]'
    setting_button = '//*[@resource-id="cool.dingstock.mobile:id/iv_setting"]'
    back_button = '//*[@resource-id="cool.dingstock.mobile:id/common_titlebar_left_icon"]'
    
    def click_private_message(self):
        """点击私信tab"""
        self.click_xpath(self.private_message_button)
        
    def click_notice_route(self):
        """点击通知tab下的路由"""
        self.click_xpath(self.comment_reply)
        self.click_xpath(self.like_button)
        self.click_xpath(self.follow_button)

    def click_notice(self):
        """点击通知tab"""
        self.click_xpath(self.notice_button)

    def click_user_list_route(self):
        """点击用户列表下路由"""
        self.click_xpath(self.user_list)
        self.click_xpath(self.my_fans)
        self.click_xpath(self.my_follow)
        title = self.get_xpath_text(self.title)
        self.click_xpath(self.back_button)
        return title
    
    def click_setting_button(self):
        """点击设置及返回"""
        self.click_xpath(self.setting_button)
        title = self.get_xpath_text(self.title)
        self.click_xpath(self.back_button)
        return title
        
    def click_clear_message_button(self):
        """清除未读消息"""
        self.click_xpath(self.clean_message_button)
        result = self.get_xpath_text(self.clean_message_confirm)
        self.click_xpath(self.clean_message_cancel)
        return result
        
        
        
    
        
